//
//  UIButton+UIButton_Extension.m
//  乐账
//
//  Created by 谢毅 on 17/1/13.
//  Copyright © 2017年 xieyi. All rights reserved.
//

#import "UIButton+UIButton_Extension.h"

@implementation UIButton (UIButton_Extension)
/// 按钮扩展方法
///(带文字的按钮)
/// @param title           按钮标题
/// @param titleSize       标题字体
/// @param image           图片
/// @param backgroundColor 背景颜色
/// @param tintColor       按钮渲染颜色
///
/// @return
+(UIButton *)createButton:(NSString *)title titleFont:(CGFloat) titleSize imageName:(NSString *)image BackgroundImage:(UIColor *)backgroundColor TintColor:(UIColor *)tintColor{
    
    UIButton *button = [[UIButton alloc] init];
    [button setTitle:title forState:UIControlStateNormal];
    if (tintColor != nil){
       [button setTintColor:tintColor];
    }
    [button setBackgroundColor:backgroundColor];
    button.titleLabel.font  = [UIFont systemFontOfSize:titleSize];

    return button;
}

/// 创建图片按钮
///
/// @param frame     按钮尺寸
/// @param imageName 按钮图片
/// @param target    监听者
/// @param action    监听方法
///
/// @return 
+(UIButton *)imageButton:(CGRect)frame setBackgroundImage:(NSString *)imageName addTarget:(nullable id)target action:(nonnull SEL)action{
    
    UIButton *button = [[UIButton alloc] initWithFrame:frame];
    [button setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return button;
}


@end
